<!DOCTYPE>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title>无标题文档</title>
		<script type="text/javascript">

			function checkUserName() {
				var un = document.getElementById("txtUserName");
				var reg = /^[a-zA-Z]\w{5,50}$/;
				var div = document.getElementById("user");
				if (reg.test(un.value)) {
					div.innerHTML = "✔";
					return true;
				} else {
					div.innerHTML = "用户名必须是字母打头长度6~20个";
					return false;
				}
			}

			function checkPwd() {
				var up = document.getElementById("txtPwd");
				var div = document.getElementById("pwd");
				if (up.value.length >= 6) {
					div.innerHTML = "✔";
					return true;
				} else {
					div.innerHTML = "密码不小于6个字符";
					return false;
				}
			}

			function checkRePwd() {
				var myreg = /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/;
				var urp = document.getElementById("txtRePwd");
				var div = document.getElementById("toPwd");
				if (myreg.test(urp.value)) {
					div.innerHTML = "✔";
					return true;
				} else {
					div.innerHTML = "手机号格式不正确";
					return false;
				}
			}
			
			function check() {
				var checkbox = document.getElementById("checkbox");
				if (checkbox.checked == true) {
					document.getElementById("button").disabled = "";
					if (checkUserName() && checkPwd() && checkRePwd()) {
						alert("成功！");
						return true;
					} else {
						return false;
					}
				} else {
					document.getElementById("button").disabled = "disabled";
				}
			}
		</script>
	</head>
	<body>
		<div>用户名</div>
		<div><input type="text" id="txtUserName" onblur="checkUserName()" /></div>
		<div id="user"></div>
		<div>密码</div>
		<div><input type="text" id="txtPwd" onblur="checkPwd()" /></div>
		<div id="pwd"></div>
		<div>手机号码</div>
		<div><input type="text" id="txtRePwd" onblur="checkRePwd()" /></div>
		<div id="toPwd"></div>
				<input type="checkbox" id="checkbox" onclick="check()" />
				<a style="text-decoration: none;" href="http://www.baidu.com">同意协议</a>
				<br />
				<input type="button" id="button" value="登录" onclick="check()" disabled="disabled" />
	</body>
</html>